﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:model="clr-namespace:PortableDeviceLib.Model;assembly=PortableDeviceLib"
                    >

    <ControlTemplate x:Key="portableDeviceObjectTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.ToolTip>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Column="0" Grid.Row="0" Text="Content type" HorizontalAlignment="Right" />
                    <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=ContentType}" Margin="5,0,0,0" />

                    <TextBlock Grid.Column="0" Grid.Row="1" Text="Format type" HorizontalAlignment="Right" />
                    <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=Format}" Margin="5,0,0,0" />
                </Grid>
            </Grid.ToolTip>

            <TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Path=ID}" />
            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=Name}" Margin="5,0,0,0" />
        </Grid>
    </ControlTemplate>

    <HierarchicalDataTemplate DataType="{x:Type model:PortableDeviceContainerObject}" ItemsSource="{Binding Path=Childs}">
        <ContentControl Content="{Binding}" Template="{StaticResource portableDeviceObjectTemplate}" />
    </HierarchicalDataTemplate>

    <DataTemplate DataType="{x:Type model:PortableDeviceObject}">
        <ContentControl Content="{Binding}" Template="{StaticResource portableDeviceObjectTemplate}" />
    </DataTemplate>


    <DataTemplate DataType="{x:Type model:PortableDeviceEventDescription}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Text="{Binding Path=Name}" />
            <ItemsControl ItemsSource="{Binding Path=Options}" />
        </Grid>
    </DataTemplate>

    <DataTemplate DataType="{x:Type model:PortableDeviceEventOption}">
        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Path=EventType}" />
    </DataTemplate>

    <Style TargetType="ItemsControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}">
                        <ItemsPresenter />
                    </ScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>